
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>音视频相关代码 · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-versions-select/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../ndk/NDK编译基础.html" />
    
    
    <link rel="prev" href="../视频相关/AAC详解.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../linux/linux基础.html">
            
                <a href="../linux/linux基础.html">
            
                    
                    linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../linux/linux基础.html">
            
                <a href="../linux/linux基础.html">
            
                    
                    linux基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../linux/android底层开发.html">
            
                <a href="../linux/android底层开发.html">
            
                    
                    android底层开发
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../c语言/c基础.html">
            
                <a href="../c语言/c基础.html">
            
                    
                    c
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../c语言/c基础.html">
            
                <a href="../c语言/c基础.html">
            
                    
                    c基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../c++/c++基础.html">
            
                <a href="../c++/c++基础.html">
            
                    
                    c++
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../c++/c++基础.html">
            
                <a href="../c++/c++基础.html">
            
                    
                    c++基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../QT/QT基础.html">
            
                <a href="../QT/QT基础.html">
            
                    
                    QT
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../QT/QT基础.html">
            
                <a href="../QT/QT基础.html">
            
                    
                    QT基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../jni/JNI基础.html">
            
                <a href="../jni/JNI基础.html">
            
                    
                    JNI
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../jni/JNI基础.html">
            
                <a href="../jni/JNI基础.html">
            
                    
                    JNI基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../jni/JNI例子.html">
            
                <a href="../jni/JNI例子.html">
            
                    
                    JNI例子
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../SDL/SDL基础.html">
            
                <a href="../SDL/SDL基础.html">
            
                    
                    SDL
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../SDL/SDL基础.html">
            
                <a href="../SDL/SDL基础.html">
            
                    
                    SDL基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../ffmpeg/ffmpeg基础.html">
            
                <a href="../ffmpeg/ffmpeg基础.html">
            
                    
                    ffmpeg
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../ffmpeg/ffmpeg基础.html">
            
                <a href="../ffmpeg/ffmpeg基础.html">
            
                    
                    ffmpeg基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../ffmpeg/ffmpeg示例代码.html">
            
                <a href="../ffmpeg/ffmpeg示例代码.html">
            
                    
                    ffmpeg示例代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../ffmpeg/ffmpeg软解rtsp简单直播.html">
            
                <a href="../ffmpeg/ffmpeg软解rtsp简单直播.html">
            
                    
                    ffmpeg软解rtsp简单直播
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../ffmpeg/rtsp服务器.html">
            
                <a href="../ffmpeg/rtsp服务器.html">
            
                    
                    rtsp服务器Windows
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../opencv/opencv模块.html">
            
                <a href="../opencv/opencv模块.html">
            
                    
                    opencv模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../opencv/opencv.html">
            
                <a href="../opencv/opencv.html">
            
                    
                    opencv
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../openSLES/openSLES基础.html">
            
                <a href="../openSLES/openSLES基础.html">
            
                    
                    openSLES
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../openSLES/openSLES基础.html">
            
                <a href="../openSLES/openSLES基础.html">
            
                    
                    openSLES基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../SoundTouch/移植SoundTouch.html">
            
                <a href="../SoundTouch/移植SoundTouch.html">
            
                    
                    SoundTouch
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../SoundTouch/移植SoundTouch.html">
            
                <a href="../SoundTouch/移植SoundTouch.html">
            
                    
                    移植SoundTouch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../SoundTouch/实现音频变速和变调.html">
            
                <a href="../SoundTouch/实现音频变速和变调.html">
            
                    
                    实现音频变速和变调
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../openGLES/openGLES基础.html">
            
                <a href="../openGLES/openGLES基础.html">
            
                    
                    openGLES模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../openGLES/openGLES基础.html">
            
                <a href="../openGLES/openGLES基础.html">
            
                    
                    openGLES基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../openGLES/GLSL基础.html">
            
                <a href="../openGLES/GLSL基础.html">
            
                    
                    GLSL基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../openGLES/openglES示例.html">
            
                <a href="../openGLES/openglES示例.html">
            
                    
                    openglES示例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../视频相关/音视频基础.html">
            
                <a href="../视频相关/音视频基础.html">
            
                    
                    音视频术语-文件格式-协议
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../视频相关/音视频基础.html">
            
                <a href="../视频相关/音视频基础.html">
            
                    
                    音视频基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../视频相关/RTSP.html">
            
                <a href="../视频相关/RTSP.html">
            
                    
                    RTSP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../视频相关/RTP.html">
            
                <a href="../视频相关/RTP.html">
            
                    
                    RTP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../视频相关/RTCP.html">
            
                <a href="../视频相关/RTCP.html">
            
                    
                    RTCP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="../视频相关/H264.html">
            
                <a href="../视频相关/H264.html">
            
                    
                    H264
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" data-path="../视频相关/YUV.html">
            
                <a href="../视频相关/YUV.html">
            
                    
                    YUV
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.7" data-path="../视频相关/SurfaceView.html">
            
                <a href="../视频相关/SurfaceView.html">
            
                    
                    SurfaceView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.8" data-path="../视频相关/RTMP.html">
            
                <a href="../视频相关/RTMP.html">
            
                    
                    RTMP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.9" data-path="../视频相关/AAC详解.html">
            
                <a href="../视频相关/AAC详解.html">
            
                    
                    AAC详解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="1.14" data-path="音视频相关代码.html">
            
                <a href="音视频相关代码.html">
            
                    
                    音视频相关代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../ndk/NDK编译基础.html">
            
                <a href="../ndk/NDK编译基础.html">
            
                    
                    NDK工程编译
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../ndk/NDK编译基础.html">
            
                <a href="../ndk/NDK编译基础.html">
            
                    
                    NDK编译基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../ndk/cmake方式.html">
            
                <a href="../ndk/cmake方式.html">
            
                    
                    cmake
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../ndk/Android.mk模板.html">
            
                <a href="../ndk/Android.mk模板.html">
            
                    
                    Android.mk
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4" data-path="../ndk/Application.mk模板.html">
            
                <a href="../ndk/Application.mk模板.html">
            
                    
                    Application.mk
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >音视频相关代码</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x97F3;&#x89C6;&#x9891;&#x76F8;&#x5173;&#x4EE3;&#x7801;"><b>1. </b>&#x97F3;&#x89C6;&#x9891;&#x76F8;&#x5173;&#x4EE3;&#x7801;</a></li><ul><li><span class="title-icon "></span><a href="#surfaceview-&#x7ED8;&#x5236;&#x56FE;&#x7247;"><b>1.1. </b>SurfaceView &#x7ED8;&#x5236;&#x56FE;&#x7247;</a></li><li><span class="title-icon "></span><a href="#audiorecord-&#x91C7;&#x96C6;&#x5E76;&#x4FDD;&#x5B58;pcm"><b>1.2. </b>AudioRecord &#x91C7;&#x96C6;&#x5E76;&#x4FDD;&#x5B58;PCM</a></li><li><span class="title-icon "></span><a href="#audiotrack-&#x64AD;&#x653E;pcm"><b>1.3. </b>AudioTrack &#x64AD;&#x653E;PCM</a></li><li><span class="title-icon "></span><a href="#pcm&#x8F6C;-wav"><b>1.4. </b>pcm&#x8F6C; wav</a></li><li><span class="title-icon "></span><a href="#wav-&#x8F6C;-pcm"><b>1.5. </b>wav &#x8F6C; pcm</a></li><li><span class="title-icon "></span><a href="#camera2-api-&#x9884;&#x89C8;&#x5E76;&#x83B7;&#x5F97;yuv&#x6570;&#x636E;"><b>1.6. </b>Camera2 API &#x9884;&#x89C8;&#x5E76;&#x83B7;&#x5F97;YUV&#x6570;&#x636E;</a></li><li><span class="title-icon "></span><a href="#mediamuxer-&#x5206;&#x79BB;-&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;"><b>1.7. </b>MediaMuxer &#x5206;&#x79BB; &#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;</a></li><li><span class="title-icon "></span><a href="#mediamuxer-&#x5C06;&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;&#x6DF7;&#x5408;"><b>1.8. </b>MediaMuxer &#x5C06;&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;&#x6DF7;&#x5408;</a></li><li><span class="title-icon "></span><a href="#mediacodec-&#x5E38;&#x7528;-api"><b>1.9. </b>MediaCodec &#x5E38;&#x7528; API</a></li><li><span class="title-icon "></span><a href="#mediacodec--camera--surfaceview--&#x9884;&#x89C8;&#x5E76;&#x4FDD;&#x5B58;-h264-&#x6587;&#x4EF6;"><b>1.10. </b>MediaCodec + camera + SurfaceView  &#x9884;&#x89C8;&#x5E76;&#x4FDD;&#x5B58; H264 &#x6587;&#x4EF6;</a></li><li><span class="title-icon "></span><a href="#camera--surfaceview--audiorecord-mediacodec--mediamuxer-&#x9884;&#x89C8;&#x5E76;&#x751F;&#x6210;-mp4&#x6587;&#x4EF6;"><b>1.11. </b>camera + SurfaceView + AudioRecord+ MediaCodec+  MediaMuxer &#x9884;&#x89C8;&#x5E76;&#x751F;&#x6210; mp4&#x6587;&#x4EF6;</a></li></ul></ul></div><a href="#&#x97F3;&#x89C6;&#x9891;&#x76F8;&#x5173;&#x4EE3;&#x7801;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x97F3;&#x89C6;&#x9891;&#x76F8;&#x5173;&#x4EE3;&#x7801;"><a name="&#x97F3;&#x89C6;&#x9891;&#x76F8;&#x5173;&#x4EE3;&#x7801;" class="anchor-navigation-ex-anchor" href="#&#x97F3;&#x89C6;&#x9891;&#x76F8;&#x5173;&#x4EE3;&#x7801;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x97F3;&#x89C6;&#x9891;&#x76F8;&#x5173;&#x4EE3;&#x7801;</h1>
<h2 id="surfaceview-&#x7ED8;&#x5236;&#x56FE;&#x7247;"><a name="surfaceview-&#x7ED8;&#x5236;&#x56FE;&#x7247;" class="anchor-navigation-ex-anchor" href="#surfaceview-&#x7ED8;&#x5236;&#x56FE;&#x7247;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. SurfaceView &#x7ED8;&#x5236;&#x56FE;&#x7247;</h2>
<pre><code class="lang-java">SurfaceView surfaceView = findViewById(R.id.surface);
surfaceView.getHolder().addCallback(<span class="hljs-keyword">new</span> SurfaceHolder.Callback() {
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">surfaceCreated</span><span class="hljs-params">(SurfaceHolder surfaceHolder)</span> </span>{
        Canvas canvas = surfaceHolder.lockCanvas();
        canvas.drawBitmap(bitmap, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, paint);
        surfaceHolder.unlockCanvasAndPost(canvas);
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">surfaceChanged</span><span class="hljs-params">(SurfaceHolder surfaceHolder, <span class="hljs-keyword">int</span> i, <span class="hljs-keyword">int</span> i1, <span class="hljs-keyword">int</span> i2)</span> </span>{   }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">surfaceDestroyed</span><span class="hljs-params">(SurfaceHolder surfaceHolder)</span> </span>{  }
});
</code></pre>
<h2 id="audiorecord-&#x91C7;&#x96C6;&#x5E76;&#x4FDD;&#x5B58;pcm"><a name="audiorecord-&#x91C7;&#x96C6;&#x5E76;&#x4FDD;&#x5B58;pcm" class="anchor-navigation-ex-anchor" href="#audiorecord-&#x91C7;&#x96C6;&#x5E76;&#x4FDD;&#x5B58;pcm"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. AudioRecord &#x91C7;&#x96C6;&#x5E76;&#x4FDD;&#x5B58;PCM</h2>
<pre><code class="lang-java">   <span class="hljs-comment">/**
    * &#x91C7;&#x6837;&#x7387;&#xFF0C;&#x73B0;&#x5728;&#x80FD;&#x591F;&#x4FDD;&#x8BC1;&#x5728;&#x6240;&#x6709;&#x8BBE;&#x5907;&#x4E0A;&#x4F7F;&#x7528;&#x7684;&#x91C7;&#x6837;&#x7387;&#x662F;44100Hz,
    * &#x4F46;&#x662F;&#x5176;&#x4ED6;&#x7684;&#x91C7;&#x6837;&#x7387;&#xFF08;22050, 16000, 11025&#xFF09;&#x5728;&#x4E00;&#x4E9B;&#x8BBE;&#x5907;&#x4E0A;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x3002;
    */</span>
   <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> SAMPLE_RATE_INHZ = <span class="hljs-number">44100</span>;

   <span class="hljs-comment">/**
    * &#x58F0;&#x9053;&#x6570;&#x3002;CHANNEL_IN_MONO and CHANNEL_IN_STEREO.
    * &#x5176;&#x4E2D;CHANNEL_IN_MONO&#x662F;&#x53EF;&#x4EE5;&#x4FDD;&#x8BC1;&#x5728;&#x6240;&#x6709;&#x8BBE;&#x5907;&#x80FD;&#x591F;&#x4F7F;&#x7528;&#x7684;&#x3002;
    */</span>
   <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_MONO;
   <span class="hljs-comment">/**
    * &#x8FD4;&#x56DE;&#x7684;&#x97F3;&#x9891;&#x6570;&#x636E;&#x7684;&#x683C;&#x5F0F;&#x3002; ENCODING_PCM_8BIT, ENCODING_PCM_16BIT, and ENCODING_PCM_FLOAT.
    */</span>
   <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
   <span class="hljs-keyword">private</span> AudioRecord audioRecord = <span class="hljs-keyword">null</span>;
   <span class="hljs-keyword">private</span> <span class="hljs-keyword">boolean</span> isRecording = <span class="hljs-keyword">false</span>;

   <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onstart</span><span class="hljs-params">(View view)</span> </span>{
       <span class="hljs-comment">// &#x4E00;&#x6B21;&#x8BFB;&#x53D6;&#x591A;&#x5C11;&#x5185;&#x5BB9;</span>
       <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> minBufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE_INHZ, CHANNEL_CONFIG, AUDIO_FORMAT);
       audioRecord = <span class="hljs-keyword">new</span> AudioRecord(MediaRecorder.AudioSource.MIC, SAMPLE_RATE_INHZ,  CHANNEL_CONFIG, AUDIO_FORMAT, minBufferSize);
       <span class="hljs-keyword">final</span> <span class="hljs-keyword">byte</span> data[] = <span class="hljs-keyword">new</span> <span class="hljs-keyword">byte</span>[minBufferSize];

       audioRecord.startRecording();
       isRecording = <span class="hljs-keyword">true</span>;

       <span class="hljs-keyword">new</span> Thread(<span class="hljs-keyword">new</span> Runnable() {
           <span class="hljs-meta">@SuppressWarnings</span>(<span class="hljs-string">&quot;AlibabaAvoidManuallyCreateThread&quot;</span>)
           <span class="hljs-meta">@Override</span>
           <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span><span class="hljs-params">()</span> </span>{
               FileOutputStream os = <span class="hljs-keyword">null</span>;
               <span class="hljs-keyword">try</span> {
                   File file = <span class="hljs-keyword">new</span> File(Environment.getExternalStorageDirectory(), <span class="hljs-string">&quot;testttttttt.pcm&quot;</span>);
                   os = <span class="hljs-keyword">new</span> FileOutputStream(file);
               } <span class="hljs-keyword">catch</span> (FileNotFoundException e) {
                   e.printStackTrace();
               }

               <span class="hljs-keyword">if</span> (<span class="hljs-keyword">null</span> != os) {
                   <span class="hljs-keyword">while</span> (isRecording) {
                       Log.i(<span class="hljs-string">&quot;aivin&quot;</span> ,<span class="hljs-string">&quot;&#x6B63;&#x5728;&#x5F55;&#x5236;&quot;</span>) ;
                       <span class="hljs-keyword">int</span> read = audioRecord.read(data, <span class="hljs-number">0</span>, minBufferSize);
                       <span class="hljs-comment">// &#x5982;&#x679C;&#x8BFB;&#x53D6;&#x97F3;&#x9891;&#x6570;&#x636E;&#x6CA1;&#x6709;&#x51FA;&#x73B0;&#x9519;&#x8BEF;&#xFF0C;&#x5C31;&#x5C06;&#x6570;&#x636E;&#x5199;&#x5165;&#x5230;&#x6587;&#x4EF6;</span>
                       <span class="hljs-keyword">if</span> (AudioRecord.ERROR_INVALID_OPERATION != read) {
                           <span class="hljs-keyword">try</span> {
                               os.write(data);
                           } <span class="hljs-keyword">catch</span> (IOException e) {
                               e.printStackTrace();
                           }
                       }
                   }
                   <span class="hljs-keyword">try</span> {
                       os.close();
                   } <span class="hljs-keyword">catch</span> (IOException e) {
                       e.printStackTrace();
                   }
               }
           }
       }).start();
   }
</code></pre>
<h2 id="audiotrack-&#x64AD;&#x653E;pcm"><a name="audiotrack-&#x64AD;&#x653E;pcm" class="anchor-navigation-ex-anchor" href="#audiotrack-&#x64AD;&#x653E;pcm"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. AudioTrack &#x64AD;&#x653E;PCM</h2>
<pre><code class="lang-xml">AudioTrack&#x6709;&#x4E24;&#x79CD;&#x6570;&#x636E;&#x52A0;&#x8F7D;&#x6A21;&#x5F0F;
MODE_STREAM &#xFF1A;&#x901A;&#x8FC7;write&#x4E00;&#x6B21;&#x6B21;&#x628A;&#x97F3;&#x9891;&#x6570;&#x636E;&#x5199;&#x5230;AudioTrack&#x4E2D;&#x3002;&#x6BCF;&#x6B21;&#x90FD;&#x9700;&#x8981;&#x628A;&#x6570;&#x636E;&#x4ECE;&#x7528;&#x6237;&#x63D0;&#x4F9B;&#x7684;Buffer&#x4E2D;&#x62F7;&#x8D1D;&#x5230;AudioTrack&#x5185;&#x90E8;&#x7684;Buffer&#x4E2D;&#xFF0C;&#x8FD9;&#x5728;&#x4E00;&#x5B9A;&#x7A0B;&#x5EA6;&#x4E0A;&#x4F1A;&#x4F7F;&#x5F15;&#x5165;&#x5EF6;&#x65F6;&#x3002;&#x9002;&#x5408;&#x5927;&#x6587;&#x4EF6;&#x3002;

MODE_STATIC &#xFF1A;&#x628A;&#x6240;&#x6709;&#x6570;&#x636E;&#x901A;&#x8FC7;&#x4E00;&#x6B21;write&#x8C03;&#x7528;&#x4F20;&#x9012;&#x5230;AudioTrack&#x4E2D;&#x7684;&#x5185;&#x90E8;&#x7F13;&#x51B2;&#x533A;&#xFF0C;&#x540E;&#x7EED;&#x5C31;&#x4E0D;&#x5FC5;&#x518D;&#x4F20;&#x9012;&#x6570;&#x636E;&#x4E86;&#x3002;
&#x8FD9;&#x79CD;&#x6A21;&#x5F0F;&#x9002;&#x7528;&#x4E8E;&#x50CF;&#x94C3;&#x58F0;&#x8FD9;&#x79CD;&#x5185;&#x5B58;&#x5360;&#x7528;&#x91CF;&#x8F83;&#x5C0F;&#xFF0C;&#x5EF6;&#x65F6;&#x8981;&#x6C42;&#x8F83;&#x9AD8;&#x7684;&#x6587;&#x4EF6;&#x3002;
</code></pre>
<pre><code class="lang-java"> <span class="hljs-comment">/**
  * &#x91C7;&#x6837;&#x7387;&#xFF0C;&#x73B0;&#x5728;&#x80FD;&#x591F;&#x4FDD;&#x8BC1;&#x5728;&#x6240;&#x6709;&#x8BBE;&#x5907;&#x4E0A;&#x4F7F;&#x7528;&#x7684;&#x91C7;&#x6837;&#x7387;&#x662F;44100Hz,
  * &#x4F46;&#x662F;&#x5176;&#x4ED6;&#x7684;&#x91C7;&#x6837;&#x7387;&#xFF08;22050, 16000, 11025&#xFF09;&#x5728;&#x4E00;&#x4E9B;&#x8BBE;&#x5907;&#x4E0A;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x3002;
  */</span>
 <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> SAMPLE_RATE_INHZ = <span class="hljs-number">44100</span>;
 <span class="hljs-comment">/**
  * &#x8FD4;&#x56DE;&#x7684;&#x97F3;&#x9891;&#x6570;&#x636E;&#x7684;&#x683C;&#x5F0F;&#x3002; ENCODING_PCM_8BIT, ENCODING_PCM_16BIT, and ENCODING_PCM_FLOAT.
  */</span>
 <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;

 <span class="hljs-comment">/**
  * &#x64AD;&#x653E;&#xFF0C;&#x4F7F;&#x7528;stream&#x6A21;&#x5F0F;
  */</span>
 <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onplay</span><span class="hljs-params">(View view)</span> </span>{
     <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> minBufferSize = AudioTrack.getMinBufferSize(SAMPLE_RATE_INHZ, AudioFormat.CHANNEL_OUT_MONO, AUDIO_FORMAT);
     <span class="hljs-keyword">final</span>  AudioTrack   audioTrack = <span class="hljs-keyword">new</span> AudioTrack(
             <span class="hljs-keyword">new</span> AudioAttributes.Builder()
                     .setUsage(AudioAttributes.USAGE_MEDIA)
                     .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
                     .build(),
             <span class="hljs-keyword">new</span> AudioFormat.Builder().setSampleRate(SAMPLE_RATE_INHZ)
                     .setEncoding(AUDIO_FORMAT)
                     .setChannelMask(AudioFormat.CHANNEL_OUT_MONO)
                     .build(),
             minBufferSize,
             AudioTrack.MODE_STREAM,
             AudioManager.AUDIO_SESSION_ID_GENERATE);
     audioTrack.play();

     File file = <span class="hljs-keyword">new</span> File(Environment.getExternalStorageDirectory(), <span class="hljs-string">&quot;testttttttt.pcm&quot;</span>);
     <span class="hljs-keyword">try</span> {
         <span class="hljs-keyword">final</span> FileInputStream  fileInputStream = <span class="hljs-keyword">new</span> FileInputStream(file);
         <span class="hljs-keyword">new</span> Thread(<span class="hljs-keyword">new</span> Runnable() {
             <span class="hljs-meta">@Override</span>
             <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span><span class="hljs-params">()</span> </span>{
                 <span class="hljs-keyword">try</span> {
                     <span class="hljs-keyword">byte</span>[] tempBuffer = <span class="hljs-keyword">new</span> <span class="hljs-keyword">byte</span>[minBufferSize];
                     <span class="hljs-keyword">while</span> (fileInputStream.available() &gt; <span class="hljs-number">0</span>) {
                         <span class="hljs-keyword">int</span> readCount = fileInputStream.read(tempBuffer);
                         <span class="hljs-keyword">if</span> (readCount == AudioTrack.ERROR_INVALID_OPERATION ||  readCount == AudioTrack.ERROR_BAD_VALUE) {
                             <span class="hljs-keyword">continue</span>;
                         }
                         <span class="hljs-keyword">if</span> (readCount != <span class="hljs-number">0</span> &amp;&amp; readCount != -<span class="hljs-number">1</span>) {
                             audioTrack.write(tempBuffer, <span class="hljs-number">0</span>, readCount);
                         }
                     }
                 } <span class="hljs-keyword">catch</span> (IOException e) {
                     e.printStackTrace();
                 }
             }
         }).start();

     } <span class="hljs-keyword">catch</span> (IOException e) {
         e.printStackTrace();
     }
 }
</code></pre>
<h2 id="pcm&#x8F6C;-wav"><a name="pcm&#x8F6C;-wav" class="anchor-navigation-ex-anchor" href="#pcm&#x8F6C;-wav"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. pcm&#x8F6C; wav</h2>
<p>&#x5728;pcm&#x6570;&#x636E;&#x524D;&#x52A0;&#x4E0A;wav&#x6587;&#x4EF6;&#x5934;&#x5373;&#x53EF;</p>
<pre><code class="lang-xml">https://www.jianshu.com/p/f7863638acbe
</code></pre>
<h2 id="wav-&#x8F6C;-pcm"><a name="wav-&#x8F6C;-pcm" class="anchor-navigation-ex-anchor" href="#wav-&#x8F6C;-pcm"><i class="fa fa-link" aria-hidden="true"></i></a>1.5. wav &#x8F6C; pcm</h2>
<p>&#x53BB;&#x6389;&#x6587;&#x4EF6;&#x5934;&#x5373;&#x53EF;</p>
<pre><code class="lang-xml">https://www.jianshu.com/p/3f80fb907bd5
</code></pre>
<h2 id="camera2-api-&#x9884;&#x89C8;&#x5E76;&#x83B7;&#x5F97;yuv&#x6570;&#x636E;"><a name="camera2-api-&#x9884;&#x89C8;&#x5E76;&#x83B7;&#x5F97;yuv&#x6570;&#x636E;" class="anchor-navigation-ex-anchor" href="#camera2-api-&#x9884;&#x89C8;&#x5E76;&#x83B7;&#x5F97;yuv&#x6570;&#x636E;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6. Camera2 API &#x9884;&#x89C8;&#x5E76;&#x83B7;&#x5F97;YUV&#x6570;&#x636E;</h2>
<pre><code class="lang-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">GetCameraActivity</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Activity</span> </span>{
    <span class="hljs-keyword">private</span> Context context;
    <span class="hljs-keyword">private</span> TextureView mPreviewView;
    <span class="hljs-keyword">private</span> Handler mHandler;
    <span class="hljs-keyword">private</span> Size mPreviewSize;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> SparseIntArray ORIENTATIONS = <span class="hljs-keyword">new</span> SparseIntArray();
    <span class="hljs-keyword">public</span> ImageReader mImageReader;
    <span class="hljs-keyword">private</span> CaptureRequest.Builder mCaptureRequest;
    <span class="hljs-comment">/**
     *  0--&gt;&#x540E;&#x7F6E;&#x76F8;&#x673A;  1---&gt; &#x524D;&#x7F6E;&#x76F8;&#x673A;
     */</span>
    <span class="hljs-keyword">private</span> String mCameraId = <span class="hljs-string">&quot;1&quot;</span>;


    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">protected</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onCreate</span><span class="hljs-params">(@Nullable Bundle savedInstanceState)</span> </span>{
        <span class="hljs-keyword">super</span>.onCreate(savedInstanceState);
        setContentView(R.layout.activity_getcamera);
        context = <span class="hljs-keyword">this</span>;

        ORIENTATIONS.append(Surface.ROTATION_0, <span class="hljs-number">90</span>);
        ORIENTATIONS.append(Surface.ROTATION_90, <span class="hljs-number">0</span>);
        ORIENTATIONS.append(Surface.ROTATION_180, <span class="hljs-number">270</span>);
        ORIENTATIONS.append(Surface.ROTATION_270, <span class="hljs-number">180</span>);

        mPreviewView = findViewById(R.id.textureview);
        mPreviewView.setSurfaceTextureListener(surfaceTextureListener);

        HandlerThread mThreadHandler = <span class="hljs-keyword">new</span> HandlerThread(<span class="hljs-string">&quot;CAMERA2&quot;</span>);
        mThreadHandler.start();
        mHandler = <span class="hljs-keyword">new</span> Handler(mThreadHandler.getLooper());

    }


    <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">startPreview</span><span class="hljs-params">(CameraDevice camera)</span> <span class="hljs-keyword">throws</span> CameraAccessException </span>{
        <span class="hljs-keyword">try</span> {
            <span class="hljs-comment">// &#x8BF7;&#x6C42;&#x9884;&#x89C8;</span>
            mCaptureRequest = camera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        } <span class="hljs-keyword">catch</span> (CameraAccessException e) {
            e.printStackTrace();
        }

        <span class="hljs-comment">// &#x81EA;&#x52A8;&#x5BF9;&#x7126;</span>
        mCaptureRequest.set(CaptureRequest.CONTROL_AF_MODE,  CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);

        <span class="hljs-comment">//&#x8BBE;&#x7F6E;&#x65B9;&#x5411;</span>
        CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
        CameraCharacteristics characteristics = manager.getCameraCharacteristics(mCameraId);
        <span class="hljs-comment">//&#x6444;&#x50CF;&#x5934;&#x4F20;&#x611F;&#x5668;&#x65B9;&#x5411;</span>
        <span class="hljs-keyword">int</span> mSensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
        <span class="hljs-comment">// &#x83B7;&#x53D6;&#x8BBE;&#x5907;&#x65B9;&#x5411;</span>
        <span class="hljs-keyword">int</span> rotation = getWindowManager().getDefaultDisplay().getRotation();
        <span class="hljs-comment">// &#x6839;&#x636E;&#x8BBE;&#x5907;&#x65B9;&#x5411;&#x8BA1;&#x7B97;&#x8BBE;&#x7F6E;&#x6444;&#x50CF;&#x5934;&#x7684;&#x65B9;&#x5411;</span>
        <span class="hljs-keyword">int</span> value = (ORIENTATIONS.get(rotation) + mSensorOrientation + <span class="hljs-number">270</span>) % <span class="hljs-number">360</span>;
        mCaptureRequest.set(CaptureRequest.JPEG_ORIENTATION, value);

        <span class="hljs-comment">// yuv&#x6570;&#x636E;&#x56DE;&#x8C03;</span>
        mImageReader = ImageReader.newInstance(mPreviewSize.getWidth(), mPreviewSize.getHeight(), ImageFormat.YUV_420_888, <span class="hljs-number">2</span>);
        mImageReader.setOnImageAvailableListener(mOnImageAvailableListener, mHandler);

        <span class="hljs-comment">// &#x4F7F;&#x9884;&#x89C8;&#x548C;yuv&#x56DE;&#x8C03;&#x751F;&#x6548;</span>
        SurfaceTexture texture = mPreviewView.getSurfaceTexture();
        texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
        Surface surface = <span class="hljs-keyword">new</span> Surface(texture);
        mCaptureRequest.addTarget(surface);
        mCaptureRequest.addTarget(mImageReader.getSurface());

        <span class="hljs-comment">// &#x521B;&#x5EFA;&#x76F8;&#x673A;&#x6355;&#x83B7;&#x4F1A;&#x8BDD;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x662F;&#x6355;&#x83B7;&#x6570;&#x636E;&#x7684;&#x8F93;&#x51FA;Surface&#x5217;&#x8868;&#xFF0C;</span>
        <span class="hljs-comment">// &#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x662F;CameraCaptureSession&#x7684;&#x72B6;&#x6001;&#x56DE;&#x8C03;&#x63A5;&#x53E3;&#xFF0C;&#x5F53;&#x5B83;&#x521B;&#x5EFA;&#x597D;&#x540E;&#x4F1A;&#x56DE;&#x8C03; onConfigured &#x65B9;&#x6CD5;</span>
        <span class="hljs-comment">// &#x7B2C;&#x4E09;&#x4E2A;&#x53C2;&#x6570;&#x7528;&#x6765;&#x786E;&#x5B9A;Callback&#x5728;&#x54EA;&#x4E2A;&#x7EBF;&#x7A0B;&#x6267;&#x884C;&#xFF0C;&#x4E3A;null&#x7684;&#x8BDD;&#x5C31;&#x5728;&#x5F53;&#x524D;&#x7EBF;&#x7A0B;&#x6267;&#x884C;</span>
        camera.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()), mSessionStateCallback, mHandler);
    }

    <span class="hljs-comment">/**
     * textureView &#x72B6;&#x6001; &#x56DE;&#x8C03;
     */</span>
    TextureView.SurfaceTextureListener surfaceTextureListener = <span class="hljs-keyword">new</span> TextureView.SurfaceTextureListener() {
        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onSurfaceTextureAvailable</span><span class="hljs-params">(SurfaceTexture surface, <span class="hljs-keyword">int</span> width, <span class="hljs-keyword">int</span> height)</span> </span>{
            <span class="hljs-keyword">try</span> {
                CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
                <span class="hljs-comment">//&#x83B7;&#x5F97;&#x6307;&#x5B9A;&#x6444;&#x50CF;&#x5934;&#x7684;&#x7279;&#x5F81;&#xFF0C;&#x652F;&#x6301;&#x7684;&#x53C2;&#x6570;</span>
                CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(mCameraId);
                StreamConfigurationMap streamConfigurationMap = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
                <span class="hljs-comment">//&#x6444;&#x50CF;&#x5934;&#x652F;&#x6301;&#x7684;&#x9884;&#x89C8;Size&#x6570;&#x7EC4;</span>
                List list = Arrays.asList(streamConfigurationMap.getOutputSizes(ImageFormat.YUV_420_888));

                Size size4 = <span class="hljs-keyword">new</span> Size(<span class="hljs-number">640</span>, <span class="hljs-number">480</span>);
                <span class="hljs-keyword">if</span> (!list.contains(size4)) {
                    <span class="hljs-comment">// &#x6839;&#x636E;TextureView&#x7684;&#x5C3A;&#x5BF8;&#x8BBE;&#x7F6E;&#x9884;&#x89C8;&#x5C3A;&#x5BF8;</span>
                    mPreviewSize = streamConfigurationMap.getOutputSizes(SurfaceTexture.class)[<span class="hljs-number">0</span>];
                } <span class="hljs-keyword">else</span> {
                    mPreviewSize = size4;
                }

                <span class="hljs-keyword">for</span> (String cameraId : cameraManager.getCameraIdList()) {
                    CameraCharacteristics characteristic
                            = cameraManager.getCameraCharacteristics(cameraId);
                    Integer facing = characteristic.get(CameraCharacteristics.LENS_FACING);
                    <span class="hljs-keyword">if</span> (facing != <span class="hljs-keyword">null</span> &amp;&amp; facing == CameraCharacteristics.LENS_FACING_BACK) {
                        mCameraId = cameraId;
                        <span class="hljs-keyword">break</span>;
                    }
                }
                <span class="hljs-comment">//&#x6253;&#x5F00;&#x76F8;&#x673A;</span>
                <span class="hljs-keyword">if</span> (ActivityCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
                    <span class="hljs-keyword">return</span>;
                }
                cameraManager.openCamera(mCameraId, mCameraDeviceStateCallback, mHandler);
            } <span class="hljs-keyword">catch</span> (CameraAccessException e) {
                e.printStackTrace();
            }
        }

        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onSurfaceTextureSizeChanged</span><span class="hljs-params">(SurfaceTexture surface, <span class="hljs-keyword">int</span> width, <span class="hljs-keyword">int</span> height)</span> </span>{
        }

        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">onSurfaceTextureDestroyed</span><span class="hljs-params">(SurfaceTexture surface)</span> </span>{
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">false</span>;
        }

        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onSurfaceTextureUpdated</span><span class="hljs-params">(SurfaceTexture surface)</span> </span>{  }
    };


    <span class="hljs-comment">/**
     * &#x76F8;&#x673A;&#x6253;&#x5F00;&#x72B6;&#x6001;&#x56DE;&#x8C03;
     */</span>
    <span class="hljs-keyword">private</span> CameraDevice.StateCallback mCameraDeviceStateCallback = <span class="hljs-keyword">new</span> CameraDevice.StateCallback() {

        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onOpened</span><span class="hljs-params">(CameraDevice camera)</span> </span>{
            <span class="hljs-keyword">try</span> {
                startPreview(camera);
            } <span class="hljs-keyword">catch</span> (CameraAccessException e) {
                e.printStackTrace();
            }
        }

        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onDisconnected</span><span class="hljs-params">(CameraDevice camera)</span> </span>{
            camera.close();
        }

        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onError</span><span class="hljs-params">(CameraDevice camera, <span class="hljs-keyword">int</span> error)</span> </span>{
            camera.close();
        }
    };

    <span class="hljs-comment">/**
     * &#x6570;&#x636E;&#x56DE;&#x8C03;&#x63A5;&#x53E3;
     */</span>
    <span class="hljs-keyword">private</span> ImageReader.OnImageAvailableListener mOnImageAvailableListener = <span class="hljs-keyword">new</span> ImageReader.OnImageAvailableListener() {
        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onImageAvailable</span><span class="hljs-params">(ImageReader reader)</span> </span>{
            Image image = reader.acquireNextImage();
            <span class="hljs-comment">//YUV_420_888&#x683C;&#x5F0F; ----&gt;&#x83B7;&#x53D6;&#x5230;&#x7684;&#x4E09;&#x4E2A;&#x901A;&#x9053; getPlanes &#x5206;&#x522B;&#x5BF9;&#x5E94;YUV</span>
            Image.Plane[] planes = image.getPlanes();
            ByteBuffer byteBufferY = planes[<span class="hljs-number">0</span>].getBuffer() ;
            <span class="hljs-keyword">byte</span>[] dataY = <span class="hljs-keyword">new</span> <span class="hljs-keyword">byte</span>[ byteBufferY.remaining()];
            byteBufferY.get(dataY) ;
            Log.i(<span class="hljs-string">&quot;aivin&quot;</span> ,<span class="hljs-string">&quot;&#x6536;&#x5230;&#x6570;&#x636E;&#x56DE;&#x8C03; Y&#x5206;&#x91CF;&#xFF1A; &quot;</span> + dataY.length);
            image.close();
        }
    };

    <span class="hljs-comment">/**
     * &#x76F8;&#x673A;&#x4F1A;&#x8BDD;&#x72B6;&#x6001;&#x63A5;&#x53E3;
     */</span>
    <span class="hljs-keyword">private</span> CameraCaptureSession.StateCallback mSessionStateCallback = <span class="hljs-keyword">new</span> CameraCaptureSession.StateCallback() {

        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onConfigured</span><span class="hljs-params">(CameraCaptureSession session)</span> </span>{
            <span class="hljs-keyword">try</span> {
                <span class="hljs-comment">//&#x8BBE;&#x7F6E;&#x53CD;&#x590D;&#x6355;&#x83B7;&#x6570;&#x636E;&#x7684;&#x8BF7;&#x6C42;&#xFF0C;&#x8FD9;&#x6837;&#x9884;&#x89C8;&#x754C;&#x9762;&#x5C31;&#x4F1A;&#x4E00;&#x76F4;&#x6709;&#x6570;&#x636E;&#x663E;&#x793A;</span>
                session.setRepeatingRequest(mCaptureRequest.build(), <span class="hljs-keyword">null</span>, mHandler);
            } <span class="hljs-keyword">catch</span> (CameraAccessException e) {
                e.printStackTrace();
            }
        }

        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onConfigureFailed</span><span class="hljs-params">(CameraCaptureSession session)</span> </span>{      }
    };
}
</code></pre>
<h2 id="mediamuxer-&#x5206;&#x79BB;-&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;"><a name="mediamuxer-&#x5206;&#x79BB;-&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;" class="anchor-navigation-ex-anchor" href="#mediamuxer-&#x5206;&#x79BB;-&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7. MediaMuxer &#x5206;&#x79BB; &#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;</h2>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">extractorVideo</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> IOException </span>{
       String inputFilePath = Environment.getExternalStorageDirectory().getPath()+<span class="hljs-string">&quot;/input.mp4&quot;</span> ;
       String outputVideoFilePath = Environment.getExternalStorageDirectory().getPath()+<span class="hljs-string">&quot;/output.mp4&quot;</span> ;
       MediaMuxer mMediaMuxer =<span class="hljs-keyword">null</span>;
       MediaExtractor mMediaExtractor = <span class="hljs-keyword">new</span> MediaExtractor();
       mMediaExtractor.setDataSource(inputFilePath);

       <span class="hljs-keyword">int</span> mVideoTrackIndex = -<span class="hljs-number">1</span>;
       <span class="hljs-keyword">int</span> framerate = <span class="hljs-number">0</span>;
       <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; mMediaExtractor.getTrackCount(); i++) {
           MediaFormat format = mMediaExtractor.getTrackFormat(i);
           String mime = format.getString(MediaFormat.KEY_MIME);
           <span class="hljs-keyword">if</span> (mime.startsWith(<span class="hljs-string">&quot;video/&quot;</span>)) {
               framerate = format.getInteger(MediaFormat.KEY_FRAME_RATE);
               <span class="hljs-comment">// &#x9009;&#x62E9;&#x89C6;&#x9891;&#x901A;&#x9053;</span>
               mMediaExtractor.selectTrack(i);
               mMediaMuxer = <span class="hljs-keyword">new</span> MediaMuxer(outputVideoFilePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
               mVideoTrackIndex = mMediaMuxer.addTrack(format);
               <span class="hljs-keyword">break</span>;
           }
       }

       MediaCodec.BufferInfo info = <span class="hljs-keyword">new</span> MediaCodec.BufferInfo();
       info.presentationTimeUs = <span class="hljs-number">0</span>;
       ByteBuffer buffer = ByteBuffer.allocate(<span class="hljs-number">1024</span> * <span class="hljs-number">1024</span>);
       <span class="hljs-keyword">int</span> dataSize ;
       mMediaMuxer.start();
       <span class="hljs-keyword">while</span> ( (dataSize = mMediaExtractor.readSampleData(buffer, <span class="hljs-number">0</span>)) &gt; <span class="hljs-number">0</span>) {
           info.offset = <span class="hljs-number">0</span>;
           info.size = dataSize;
           info.flags = MediaCodec.BUFFER_FLAG_SYNC_FRAME;
           info.presentationTimeUs += <span class="hljs-number">1000</span> * <span class="hljs-number">1000</span> / framerate;
           mMediaMuxer.writeSampleData(mVideoTrackIndex, buffer, info);
           <span class="hljs-comment">// &#x7EE7;&#x7EED;&#x8BFB;&#x53D6;&#x4E0B;&#x4E00;&#x5E27;&#x6570;&#x636E;</span>
           mMediaExtractor.advance();
       }
       mMediaExtractor.release();
       mMediaMuxer.stop();
       mMediaMuxer.release();
   }

<span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">extractorAudio</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> IOException </span>{
      String inputFilePath = Environment.getExternalStorageDirectory().getPath()+<span class="hljs-string">&quot;/input.mp4&quot;</span> ;
      String outputVideoFilePath = Environment.getExternalStorageDirectory().getPath()+<span class="hljs-string">&quot;/output.mp3&quot;</span> ;
      MediaMuxer mMediaMuxer =<span class="hljs-keyword">null</span>;
      MediaExtractor mMediaExtractor = <span class="hljs-keyword">new</span> MediaExtractor();
      mMediaExtractor.setDataSource(inputFilePath);

      <span class="hljs-keyword">int</span> mVideoTrackIndex = -<span class="hljs-number">1</span>;
      <span class="hljs-keyword">int</span> framerate = <span class="hljs-number">0</span>;
      <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; mMediaExtractor.getTrackCount(); i++) {
          MediaFormat format = mMediaExtractor.getTrackFormat(i);
          String mime = format.getString(MediaFormat.KEY_MIME);
          <span class="hljs-keyword">if</span> (mime.startsWith(<span class="hljs-string">&quot;audio/&quot;</span>)) {
              <span class="hljs-comment">// &#x9009;&#x62E9;&#x89C6;&#x9891;&#x901A;&#x9053;</span>
              mMediaExtractor.selectTrack(i);
              mMediaMuxer = <span class="hljs-keyword">new</span> MediaMuxer(outputVideoFilePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
              mVideoTrackIndex = mMediaMuxer.addTrack(format);
          }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(mime.startsWith(<span class="hljs-string">&quot;video/&quot;</span>)){
              framerate = format.getInteger(MediaFormat.KEY_FRAME_RATE);
          }
      }

      MediaCodec.BufferInfo info = <span class="hljs-keyword">new</span> MediaCodec.BufferInfo();
      info.presentationTimeUs = <span class="hljs-number">0</span>;
      ByteBuffer buffer = ByteBuffer.allocate(<span class="hljs-number">1024</span> * <span class="hljs-number">1024</span>);
      <span class="hljs-keyword">int</span> dataSize ;
      mMediaMuxer.start();
      <span class="hljs-keyword">while</span> ( (dataSize = mMediaExtractor.readSampleData(buffer, <span class="hljs-number">0</span>)) &gt; <span class="hljs-number">0</span>) {
          info.offset = <span class="hljs-number">0</span>;
          info.size = dataSize;
          info.flags = MediaCodec.BUFFER_FLAG_SYNC_FRAME;
          info.presentationTimeUs += <span class="hljs-number">1000</span> * <span class="hljs-number">1000</span> / framerate;
          mMediaMuxer.writeSampleData(mVideoTrackIndex, buffer, info);
          <span class="hljs-comment">// &#x7EE7;&#x7EED;&#x8BFB;&#x53D6;&#x4E0B;&#x4E00;&#x5E27;&#x6570;&#x636E;</span>
          mMediaExtractor.advance();
      }
      mMediaExtractor.release();
      mMediaMuxer.stop();
      mMediaMuxer.release();
  }
</code></pre>
<h2 id="mediamuxer-&#x5C06;&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;&#x6DF7;&#x5408;"><a name="mediamuxer-&#x5C06;&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;&#x6DF7;&#x5408;" class="anchor-navigation-ex-anchor" href="#mediamuxer-&#x5C06;&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;&#x6DF7;&#x5408;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8. MediaMuxer &#x5C06;&#x97F3;&#x9891;&#x3001;&#x89C6;&#x9891;&#x6DF7;&#x5408;</h2>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">mixVedioAndAudio</span><span class="hljs-params">()</span> </span>{
    String inputVedioPath = Environment.getExternalStorageDirectory().getPath()+<span class="hljs-string">&quot;/input.mp4&quot;</span> ;
    String inputAudioPath = Environment.getExternalStorageDirectory().getPath()+<span class="hljs-string">&quot;/input.mp3&quot;</span> ;
    String outputVideoFilePath = Environment.getExternalStorageDirectory().getPath()+<span class="hljs-string">&quot;/output.mp4&quot;</span> ;

    MediaExtractor videoExtractor ;
    MediaExtractor audioExtractor ;
    MediaMuxer mixMediaMuxer ;

    <span class="hljs-keyword">int</span> framerate = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">try</span> {
        videoExtractor = <span class="hljs-keyword">new</span> MediaExtractor();
        videoExtractor.setDataSource(inputVedioPath);
        <span class="hljs-keyword">int</span> videoIndex = -<span class="hljs-number">1</span>;
        MediaFormat videoTrackFormat = <span class="hljs-keyword">null</span>;
        <span class="hljs-keyword">int</span> trackCount = videoExtractor.getTrackCount();
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; trackCount; i++) {
            videoTrackFormat = videoExtractor.getTrackFormat(i);
            <span class="hljs-keyword">if</span> (videoTrackFormat.getString(MediaFormat.KEY_MIME).startsWith(<span class="hljs-string">&quot;video/&quot;</span>)) {
                videoIndex = i;
                framerate = videoTrackFormat.getInteger(MediaFormat.KEY_FRAME_RATE);
            }
        }

        audioExtractor = <span class="hljs-keyword">new</span> MediaExtractor();
        audioExtractor.setDataSource(inputAudioPath);
        <span class="hljs-keyword">int</span> audioIndex = -<span class="hljs-number">1</span>;
        MediaFormat audioTrackFormat = <span class="hljs-keyword">null</span>;
        trackCount = audioExtractor.getTrackCount();
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; trackCount; i++) {
            audioTrackFormat = audioExtractor.getTrackFormat(i);
            <span class="hljs-keyword">if</span> (audioTrackFormat.getString(MediaFormat.KEY_MIME).startsWith(<span class="hljs-string">&quot;audio/&quot;</span>)) {
                audioIndex = i;
            }
        }

        videoExtractor.selectTrack(videoIndex);
        audioExtractor.selectTrack(audioIndex);

        mixMediaMuxer = <span class="hljs-keyword">new</span> MediaMuxer(outputVideoFilePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
        <span class="hljs-keyword">int</span> videoTrackIndex = mixMediaMuxer.addTrack(videoTrackFormat);
        <span class="hljs-keyword">int</span> audioTrackIndex = mixMediaMuxer.addTrack(audioTrackFormat);
        mixMediaMuxer.start();

        ByteBuffer byteBuffer = ByteBuffer.allocate(<span class="hljs-number">1024</span> * <span class="hljs-number">1024</span>);
        MediaCodec.BufferInfo videoBufferInfo = <span class="hljs-keyword">new</span> MediaCodec.BufferInfo();
        MediaCodec.BufferInfo audioBufferInfo = <span class="hljs-keyword">new</span> MediaCodec.BufferInfo();
        <span class="hljs-keyword">while</span> (<span class="hljs-keyword">true</span>) {
            <span class="hljs-keyword">int</span> data = videoExtractor.readSampleData(byteBuffer, <span class="hljs-number">0</span>);
            <span class="hljs-keyword">if</span> (data &lt; <span class="hljs-number">0</span>) {
                <span class="hljs-keyword">break</span>;
            }
            videoBufferInfo.size = data;
            videoBufferInfo.presentationTimeUs +=  <span class="hljs-number">1000</span> *<span class="hljs-number">1000</span> /framerate;
            videoBufferInfo.offset = <span class="hljs-number">0</span>;
            videoBufferInfo.flags = MediaCodec.BUFFER_FLAG_SYNC_FRAME;

            mixMediaMuxer.writeSampleData(videoTrackIndex, byteBuffer, videoBufferInfo);
            videoExtractor.advance();
        }

        <span class="hljs-keyword">while</span> (<span class="hljs-keyword">true</span>) {
            <span class="hljs-keyword">int</span> data = audioExtractor.readSampleData(byteBuffer, <span class="hljs-number">0</span>);
            <span class="hljs-keyword">if</span> (data &lt; <span class="hljs-number">0</span>) {
                <span class="hljs-keyword">break</span>;
            }
            audioBufferInfo.size = data;
            audioBufferInfo.presentationTimeUs +=  <span class="hljs-number">1000</span> *<span class="hljs-number">1000</span> /framerate;
            audioBufferInfo.offset = <span class="hljs-number">0</span>;
            audioBufferInfo.flags = MediaCodec.BUFFER_FLAG_SYNC_FRAME;

            mixMediaMuxer.writeSampleData(audioTrackIndex, byteBuffer, audioBufferInfo);
            audioExtractor.advance();
        }

        mixMediaMuxer.stop();
        mixMediaMuxer.release();
        videoExtractor.release();
        audioExtractor.release();
    } <span class="hljs-keyword">catch</span> (IOException e) {
        e.printStackTrace();
    }
}
</code></pre>
<h2 id="mediacodec-&#x5E38;&#x7528;-api"><a name="mediacodec-&#x5E38;&#x7528;-api" class="anchor-navigation-ex-anchor" href="#mediacodec-&#x5E38;&#x7528;-api"><i class="fa fa-link" aria-hidden="true"></i></a>1.9. MediaCodec &#x5E38;&#x7528; API</h2>
<pre><code class="lang-java"><span class="hljs-keyword">return</span> the output image, or <span class="hljs-keyword">null</span> <span class="hljs-keyword">if</span>  ... or <span class="hljs-keyword">if</span> the codec  was configured with an output surface.
mMeidaCodec.getOutputImage(outputBufferIndex) ;

<span class="hljs-comment">// &#x6CE8;&#x610F;&#xFF1A; &#x5982;&#x679C;&#x914D;&#x7F6E;&#x4E86; surfaceview&#xFF0C; &#x6570;&#x636E;&#x5C31;&#x88AB;&#x6D88;&#x8017;&#x6389;&#x4E86; &#xFF0C;&#x5C31;&#x62FF;&#x4E0D;&#x5230;&#x89E3;&#x7801;&#x540E;&#x7684;&#x6570;&#x636E;&#x4E86; &#x3002;</span>
mMeidaCodec.configure(mediaFormat, mSurfaceView.getHolder().getSurface(), <span class="hljs-keyword">null</span>, <span class="hljs-number">0</span>);
</code></pre>
<h2 id="mediacodec--camera--surfaceview--&#x9884;&#x89C8;&#x5E76;&#x4FDD;&#x5B58;-h264-&#x6587;&#x4EF6;"><a name="mediacodec--camera--surfaceview--&#x9884;&#x89C8;&#x5E76;&#x4FDD;&#x5B58;-h264-&#x6587;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#mediacodec--camera--surfaceview--&#x9884;&#x89C8;&#x5E76;&#x4FDD;&#x5B58;-h264-&#x6587;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.10. MediaCodec + camera + SurfaceView  &#x9884;&#x89C8;&#x5E76;&#x4FDD;&#x5B58; H264 &#x6587;&#x4EF6;</h2>
<p>java&#x5B9E;&#x73B0;</p>
<pre><code class="lang-xml">https://gitee.com/hnyer/codeSnippet/tree/master/onlyh264
</code></pre>
<h2 id="camera--surfaceview--audiorecord-mediacodec--mediamuxer-&#x9884;&#x89C8;&#x5E76;&#x751F;&#x6210;-mp4&#x6587;&#x4EF6;"><a name="camera--surfaceview--audiorecord-mediacodec--mediamuxer-&#x9884;&#x89C8;&#x5E76;&#x751F;&#x6210;-mp4&#x6587;&#x4EF6;" class="anchor-navigation-ex-anchor" href="#camera--surfaceview--audiorecord-mediacodec--mediamuxer-&#x9884;&#x89C8;&#x5E76;&#x751F;&#x6210;-mp4&#x6587;&#x4EF6;"><i class="fa fa-link" aria-hidden="true"></i></a>1.11. camera + SurfaceView + AudioRecord+ MediaCodec+  MediaMuxer &#x9884;&#x89C8;&#x5E76;&#x751F;&#x6210; mp4&#x6587;&#x4EF6;</h2>
<p>java&#x5B9E;&#x73B0;</p>
<pre><code class="lang-xml">https://gitee.com/hnyer/codeSnippet/tree/master/muxer
</code></pre>
<footer class="page-footer"><span class="copyright">&#x65E0;&#x7248;&#x6743; &#x53EF;&#x4EE5;&#x65E0;&#x9650;&#x5236;&#x4F7F;&#x7528;&#xFF01; all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2020-08-20 14:17:31
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../视频相关/AAC详解.html" class="navigation navigation-prev " aria-label="Previous page: AAC详解">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../ndk/NDK编译基础.html" class="navigation navigation-next " aria-label="Next page: NDK工程编译">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"音视频相关代码","level":"1.14","depth":1,"next":{"title":"NDK工程编译","level":"1.15","depth":1,"path":"chinese/ndk/NDK编译基础.md","ref":"chinese/ndk/NDK编译基础.md","articles":[{"title":"NDK编译基础","level":"1.15.1","depth":2,"path":"chinese/ndk/NDK编译基础.md","ref":"chinese/ndk/NDK编译基础.md","articles":[]},{"title":"cmake","level":"1.15.2","depth":2,"path":"chinese/ndk/cmake方式.md","ref":"chinese/ndk/cmake方式.md","articles":[]},{"title":"Android.mk","level":"1.15.3","depth":2,"path":"chinese/ndk/Android.mk模板.md","ref":"chinese/ndk/Android.mk模板.md","articles":[]},{"title":"Application.mk","level":"1.15.4","depth":2,"path":"chinese/ndk/Application.mk模板.md","ref":"chinese/ndk/Application.mk模板.md","articles":[]}]},"previous":{"title":"AAC详解","level":"1.13.9","depth":2,"path":"chinese/视频相关/AAC详解.md","ref":"chinese/视频相关/AAC详解.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","versions-select","fontsettings","sharing","tbfed-pagefooter","donate","local-video","splitter","edit-link","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"无版权 可以无限制使用！","modify_label":"该文件更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"versions-select":{"type":"branches"},"donate":{"alipay":"https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803011956_osChina_支付宝收款码.png","alipayText":"支付宝打赏","button":"打赏","title":"","wechat":"https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803011956_osChina_微信收款码.png","wechatText":"微信打赏"},"fontsettings":{"family":"sans","size":2,"theme":"sepia"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"versions":{"options":[{"value":"https://www.aivin666.cn/java_android/","text":"v1.0"}]},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":false,"google":true,"instapaper":false,"twitter":false,"vk":false,"weibo":true},"edit-link":{"label":"托管页面","base":"https://www.baidu.com/"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/音视频相关代码/音视频相关代码.md","mtime":"2020-08-20T06:17:31.537Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-08-20T09:02:41.305Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-versions-select/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

